//
//  FileCell.m
//  ChangChat
//
//  Created by Cocoa on 2019/10/10.
//  Copyright © 2019 yibai. All rights reserved.
//

#import "FileCell.h"

@implementation FileCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    
    self.fileImgView = [UIImageView new];
    self.fileImgView.image = UIImage.k_imgName(@"msg_placeholder_file");
    self.fileNameLabel = [UILabel k_labelWithFontSize:15 textColor:UIColor.k_t2Color];
    self.fileNameLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
    self.fileNameLabel.numberOfLines = 2;
    self.fileSizeLabel = [UILabel k_labelWithFontSize:12 textColor:UIColor.k_t3Color];
    self.rightImgView = [[UIImageView alloc] initWithImage:UIImage.k_imgName(@"arrow_right")];

    [self.contentView addSubview:self.fileImgView];
    [self.contentView addSubview:self.fileNameLabel];
    [self.contentView addSubview:self.fileSizeLabel];
    [self.contentView addSubview:self.rightImgView];
    
    
    [self.fileImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_offset(15);
        make.size.mas_equalTo(CGSizeMake(40, 43));
        make.bottom.mas_offset(-15).priorityLow();
    }];
    
    [self.fileNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.fileImgView.mas_right).offset(5);
        make.right.equalTo(self.rightImgView.mas_left).offset(-10);
        make.top.equalTo(self.fileImgView);
    }];
    [self.rightImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_offset(0);
        make.right.mas_offset(-15);
        make.size.mas_equalTo(CGSizeMake(6, 11));
    }];
    
    [self.fileSizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.fileNameLabel);
        make.top.equalTo(self.fileNameLabel.mas_bottom).offset(5);
        make.bottom.lessThanOrEqualTo(self.contentView).offset(-10);
    }];
}

@end
